home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / MATH / SOLVEQ10.ZIP / SOLVEQ.DOC < prev    next >
Text File  |  1992-04-06  |  5KB  |  94 lines

  1. ===============================================================================
  2.                                  SOLVEQ.DOC
  3. ===============================================================================
  4.  
  5.          SOLVEQ is a  Turbo Pascal program that solves algebraic (polynomial)
  6. equations. Its main procedure is called  SolveEquation  and it is in EQUATION
  7. unit interface. The greatest degree allowed is MaxDegree = 30.
  8.  
  9.          SolveEquation's syntax is
  10.  
  11.  procedure SolveEquation(a: polynomial; option: byte; var answer: solutions)
  12.  
  13.          where polynomial  and solutions are the following records defined at
  14. EQUATION interface:
  15.  
  16.      polynomial = record
  17.        coef: array[0..MaxDegree + 1] of real;  { equation's coefficients }
  18.        degree: byte;                           { equation's degree       }
  19.      end;
  20.  
  21.      complex = record
  22.        Re, Im: real;
  23.        method: string[5];
  24.      end;
  25.  
  26.      solutions = record
  27.        x: array[1..MaxDegree] of complex;              { equation's roots }
  28.        solved: boolean;     { tells whether the resolution was successful }
  29.      end;
  30.  
  31.          The value  of  the option  parameter (0 or 1) limits some constants
  32. values used during the resolution. The 0 option defines small values to some
  33. constants and the 1 option greater values. With the 0 option the equation is
  34. solved more quickly, but some equations can only be solved with the 1 option.
  35.  
  36.          The degree and equation's coefficients  must  be  furnished  during
  37. the execution of the program. The coefficients must be ordered following the
  38. decreasing powers of 'x'. For example, the equation
  39.  
  40.                    8       7    6       4      2
  41.                   x  - 13 x  + x  - 10 x  + 2 x  - 5 x + 25 = 0
  42.  
  43. is solved, furnishing the following numbers as its coefficients
  44.  
  45.                  1    -13    1    0    -10    0    2    -5    25
  46.  
  47.          In this case, will be showed an answer like
  48.  
  49.     -----------------------------------------------------------------
  50.        #         real part        imaginary part     test    method
  51.     -----------------------------------------------------------------
  52.        1        0.7016937844        0.9499812958       R     Brstw
  53.        2        0.7016937844       -0.9499812958       R     Brstw
  54.        3       12.9272681736        0.0000000000       R     Brstw
  55.        4        1.0083042182        0.0000000000       R     Brstw
  56.        5       -1.0402275406        0.4352425025       R     Brstw
  57.        6       -1.0402275406       -0.4352425025       R     Brstw
  58.        7       -0.1292524396        1.0318542107       R     SecDg
  59.        8       -0.1292524396       -1.0318542107       R     SecDg
  60.     -----------------------------------------------------------------
  61.  
  62.        Begin at 11:24:48:38                    End at 11:24:49:32
  63.  
  64.  
  65.          All found solution is tested.  If the 'test'  column has a 'R' (from
  66. Right) so the found solution was substituted in the equation  and the  result
  67. is a complex number whose absolute value is less then error = 0.0000000001. If
  68. appears an 'I' (from Inverse) in the test column means that  1/z  substituted
  69.      n
  70. in  x p(1/x)  gives a number whose modulus is less then error, and therefore,
  71. z is really a root of p(x).  If appears an  'E' (from Error)  at  the  column
  72. test, this means that something is not going well.
  73.          The method column shows which method was used  to  find  that  root:
  74. Brstw  (Bairstow's  algorithm),  Gauss  (root  in  the form  a + bi,  a and b
  75. integers), Ratnl (rational root), SecDg  (2nd. degree equation),  FstDg (1st.
  76. degree  equation), Integ (integer root), Subst (some substition of  the  form
  77.      n
  78. y = x   was used with some other algorithm).
  79.          The time when the  resolution  begins  and  finishes is shown in the
  80. format hours:minutes:seconds:cents_seconds.
  81.  
  82.          The program that uses the EQUATION unit must have the compiler direc-
  83. tive {$E+,N+,F+} as one of the initial lines of the program.
  84.          See the simple  source  program  EQDEMO.PAS showing how to  use  the
  85. procedure or type mentionated above.
  86.  
  87.          All the procedures  or  data types  mentionated  before  are  only a
  88. small part  of the  Computational Linear Algebra Project, that is a colection
  89. of programs  in  permanent evolution. It's  probabily  available  at the same
  90. place you got these  files.  Any comment or hint  will be apreciated  if  you
  91. send them to CCENDM03@BRUFPB.BITNET.
  92.  
  93. ===============================================================================
  94.